<template>
  <div class="tabbar">
    <div
      @click="handleClick(index)"
      :class="{ active: currentIndex == index }"
      class="btn"
      v-for="(item, index) in tablist"
      :key="index"
    >
      <!-- <img :src="item.pic" alt=""> -->
      <div>{{ item.text }}</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentIndex: 0,
      tablist: [
        {
          pic: "",
          text: "首页",
        },
        {
          pic: "",
          text: "爆爆团",
        },
        {
          pic: "",
          text: "订单",
        },

        {
          pic: "",
          text: "我的",
        },
      ],
    };
  },
  methods: {
    handleClick(index) {
      this.currentIndex = index; //保存当前点击按钮的下标
    },
  },
};
</script>
<style lang="scss" scoped>
.tabbar {
  display: flex;
  justify-content: space-around;
  text-align: center;
  align-content: center;
  position: fixed;
  bottom: 0;
  width: 100%;
  padding: 10px 0;
  border-top: 1px solid #ccc;
}
.tabbar .active {
  color: lightskyblue;
}
</style>